package OtherPubs;

import Rout.*;
import com.sun.org.omg.SendingContext.CodeBasePackage.URLSeqHelper;
import java.util.ArrayList;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebElement;
import org.testng.annotations.*;

public class DesctopResearch {

    private GoBefore browser = new GoBefore();
    private ArrayList<String> urls = new ArrayList<String>();
    private JavascriptExecutor js = (JavascriptExecutor) browser.getDriver();
    private int attempt = 5;   // how much we'll try for catch events
    private WebElement downlButton;
    private ArrayList<String> newTab;

    @BeforeMethod
    public void setUp() throws Exception {
        urls.add("http://n131adserv.com/ads?key=39d26afda1117d1f7d798ecbdabefcd8&width=0&height=0");
        
        System.out.println("\n Run test: " + getClass().getSimpleName());
        browser.setXpFilename(null);
//        browser.setRepDir(getClass().getSimpleName());
        browser.setEnableSafeBrow(Boolean.FALSE);
        browser.setChDrvPath("/home/user/Dropbox/WebDriver/lin64/chromedriver");
//        browser.setRemoteDriver("192.168.5.193"); //Win7Clone VBox
//        browser.setRemoteDriver("192.168.4.170"); //VMWare net sbapshot selen-ready
//        browser.setProxy("49.151.104.242", "3128"); //Ph
        

        browser.setUserAg(1);
        browser.resizeBrowser(1980, 1080);
        
        browser.setCssButton("");
        browser.setXpButton("");
    }


    @Test //Void Footer Baner
    public void Test() throws Exception {

        for (String url : urls) {

            browser.setCurURL(url);
            System.out.println("\n\nTest case: " + (urls.indexOf(url) + 1));

            browser.setUp();            
            
            for (int m = 0; m < attempt; m++) {
            browser.getDriver().get(url);
            browser.ipDetect();
            browser.setRepDir("test_" + (urls.indexOf(url) + 1) + "_" + browser.detectGEO());
                        
            browser.refreshCurlURL(1, 1);

            System.out.println("\nTest URL is: " + url);
                            
                System.out.println("attempt :" + m);
                              
//                browser.testRun();
                Thread.sleep(1000);
                browser.getThisURL();
                browser.takeFoto();
                //sout for jira markup
                System.out.println("!" + browser.getFotoName() + "|thumbnail!");
                            
            Thread.sleep(1000);                   

            }
            }
            
    }

    @AfterMethod
    public void Down() throws Exception {
        browser.getDriver().quit();

    }

}
